using System;
using System.Collections.Generic;
using System.Text;

namespace RapidHDL
{
    
    public class State
    {
        public string StateName;
        public Component ParentComponent;
        public Constant StateConstant;
        public bool IsUsed;
        public Condition TransitionCondition;
        public NodeVector StateCurrentNodes;
        public int Code;

        public State(Component poParentComponent, string psStateName,int piCode)
        {
            ParentComponent = poParentComponent;
            StateCurrentNodes = new NodeVector(ParentComponent,"S_" + psStateName + "_hot",1);
            IsUsed = false;
            Code = piCode;
            TransitionCondition = new Condition(ParentComponent, "next_S_" + psStateName);
            StateName = psStateName;            
        }

        public void CreateConstant(int piWidth)
        {
            StateConstant = new Constant(ParentComponent, "S_" + StateName, Conversion.CodeOneHot(Code,piWidth));                
        }
    }
}
